package com.imooc.miaosha.controller.BackController;

import com.imooc.miaosha.util.JedisUtil;
import com.imooc.miaosha.util.JsonData;
import com.imooc.miaosha.util.RedisCheck;
import com.imooc.miaosha.vo.JedisResp;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("check")
public class CheckController {
    @RequestMapping("/checkredis")
    public List<JedisResp> pingAllJedis() {
        RedisCheck redisCheck = new RedisCheck();
        return redisCheck.pingAllJedisInMap();
    }

    @RequestMapping("/foreachRedisClientMap")
    public Map<String, Jedis> foreach() {
        RedisCheck redisCheck = new RedisCheck();
        return redisCheck.foeachAllJedis();
    }

    @RequestMapping("/addRedisClient")
    public Map<String, Object> addRedis(String name, String ip, Integer port, String pass) {
        RedisCheck redisCheck = new RedisCheck();
        Jedis jedis = new Jedis(ip, port);

        return redisCheck.addJedis(name, jedis, pass);

    }

}
